#include "stdafx.h"
#include "CBuffer.h"


CBuffer::CBuffer()
	: m_pBytes(0), m_iStrike(4), m_iPitch(0), m_iWidth(0), m_iHeight(0)
{

}

CBuffer::~CBuffer()
{

}

byte_t * CBuffer::GetBuffer() const
{
	return m_pBytes;
}

int_32 CBuffer::GetStrike() const
{
	return m_iStrike;
}

int_32 CBuffer::GetWidth() const
{
	return m_iWidth;
}

int_32 CBuffer::GetPitch() const
{
	return m_iPitch;
}

int_32 CBuffer::GetHeight() const
{
	return m_iHeight;
}

void CBuffer::SetSize(int_32 iWidth, int_32 iHeight, int_32 iStrike/* = 4*/)
{
	int_32 iBits = (iStrike << 3) - 1;
	int_32 iPitch = ((iWidth + iBits) & ~iBits) >> 3;
	byte_t * pNewBytes = new byte_t[m_iPitch * m_iHeight];
	VerifyPointer(pNewBytes);

	if(m_pBytes)
		delete[] m_pBytes;

	m_pBytes = pNewBytes;
	m_iStrike = iStrike;
	m_iPitch = iPitch;
	m_iWidth = iWidth;
	m_iHeight = iHeight;
}
